package com.shiyingzi.auser.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.shiyingzi.auser.model.AChannel;
import com.shiyingzi.auser.service.AChannelService;
import com.shiyingzi.common.PageableData;
import com.shiyingzi.common.ResponseData;

@RestController
@RequestMapping(value = "achannel")
public class AChannelController {	
	@Resource(name = AChannelService.BEAN_ID)
	private AChannelService aChannelService;
	
	@RequestMapping(value = "/ainesrt", method = {RequestMethod.GET,RequestMethod.POST })
	public ResponseData inserAChannel(AChannel code){
		return aChannelService.addAChannel(code);
	}
	
	@RequestMapping(value = "/query", method = { RequestMethod.GET, RequestMethod.POST })
	public PageableData<AChannel> doQuery(int page, int limit, String chName){
		return aChannelService.queryAChannelList(page, limit, chName);
	}
	@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
	public ResponseData update(AChannel code){
		return aChannelService.updateAChannel(code);
	}
	@RequestMapping(value = "/findlist", method = { RequestMethod.GET, RequestMethod.POST })
	public List<AChannel> findlist(){
		return aChannelService.findlistBystate();
	}
	@RequestMapping(value = "/findAllList", method = { RequestMethod.GET, RequestMethod.POST })
	public List<AChannel> findAllList(){
		return aChannelService.findAllList();
	}
	@RequestMapping(value = "/updateStateById", method = { RequestMethod.GET, RequestMethod.POST })
	public ResponseData updateStateById(AChannel code){
		AChannel code2=aChannelService.getAChannelById(code.getId());
		code2.setChState(code.getChState());
		return aChannelService.updateAChannel(code2);
	}
}
